package com.youmu.sichuansfc.controller.fundV2;

import com.youmu.sichuansfc.ano.FundManager.FundUserTokenUser;
import com.youmu.sichuansfc.common.CommonRes;
import com.youmu.sichuansfc.controller.BaseController;
import com.youmu.sichuansfc.domain.YoumuFundUser;
import com.youmu.sichuansfc.dto.PageT;
import com.youmu.sichuansfc.service.FundManagerService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping(value = "/y2")
public class fundManagerController extends BaseController{

    private Logger logger = Logger.getLogger(this.getClass());
    @Autowired
    FundManagerService fundManagerService;

    /**
     *  查询基金管理人的报送信息
     * @param youmuFundUser
     * @param num
     * @param size
     * @return
     */
    @RequestMapping(value = "/fund/managers/history.bs", method = RequestMethod.GET)
    public @ResponseBody
    CommonRes fundManagers(@FundUserTokenUser YoumuFundUser youmuFundUser,
                           @RequestParam(name = "num", required = false, defaultValue = "0") int  num,
                           @RequestParam(name = "size", required = false, defaultValue = "10") int size){
        try {
            PageT pageT = fundManagerService.funManagersByUser(youmuFundUser, num, size);
            return  CommonRes.success(pageT);
        }catch (Exception e){
            e.printStackTrace();
        }

        return CommonRes.fail();
    }

    /**
     *  拉起基金列表
     * @param youmuFundUser
     * @param num
     * @param size
     * @return
     */
    @RequestMapping(value = "/fund/managers/fund/list.bs", method = RequestMethod.GET)
    public @ResponseBody
    CommonRes fundManagerfundList(@FundUserTokenUser YoumuFundUser youmuFundUser,
                           @RequestParam(name = "num", required = false, defaultValue = "0") int  num,
                           @RequestParam(name = "size", required = false, defaultValue = "10") int size){
        try {
            PageT pageT = fundManagerService.findFundListByFundUserId(youmuFundUser.getId(), num, size);
            return  CommonRes.success(pageT);
        }catch (Exception e){
            e.printStackTrace();
        }

        return CommonRes.fail();
    }

    /**
     *  拉起基金列表
     * @param youmuFundUser
     * @param num
     * @param size
     * @return
     */
    @RequestMapping(value = "/fund/managers/fund/history.bs", method = RequestMethod.GET)
    public @ResponseBody
    CommonRes fundManagerfundHistory(@FundUserTokenUser YoumuFundUser youmuFundUser,
                                  @RequestParam(name = "num", required = false, defaultValue = "0") int  num,
                                  @RequestParam(name = "size", required = false, defaultValue = "10") int size,
                                  @RequestParam(name = "fundId") Long fundId){
        try {
            PageT pageT = fundManagerService.findHistoryByFundUserId(youmuFundUser.getId(), num, size, fundId);
            return  CommonRes.success(pageT);
        }catch (Exception e){
            e.printStackTrace();
        }

        return CommonRes.fail();
    }
}
